class Solution {
public:
    vector<string> ret;
    string ans;
    string hashmap[10] = {"","","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    
    void backtrace(string& s,int cur){
        if(cur == s.size()){
            ret.push_back(ans);
            return;
        }
        string digits = hashmap[s[cur] - '0'];
        for(int i = 0;i < digits.size();i++){
            ans.push_back(digits[i]);
            backtrace(s,cur+1);
            ans.pop_back();
        }
    }
    
    vector<string> letterCombinations(string digits) {
        if(digits.size() == 0) return ret;
        backtrace(digits,0);
        return ret;
    }
};
